import axios, { type AxiosPromise } from "axios"
// 创建 axios 实例
export const service = axios.create({
     baseURL: "http://localhost:8088/StuService_war_exploded",
    // baseURL:"http://localhost:8090/MyService2_war_exploded/",
    timeout: 50000,
    headers: { 'Content-Type': 'application/json;charset=utf-8' }
});

export function registerForService(data:UserModel):AxiosPromise<any> {
    // var formData = new FormData();
    // formData.append("username", data.username!!);
    // formData.append("password", data.password!!);
    return service({
      url: '/user/registerApi',
      method: 'post',
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: data,
    });
}

export function loginForService(data:UserModel): AxiosPromise<any> {
    // var formData = new FormData();
    // formData.append("username", data.username!!);
    // formData.append("password", data.password!!);
    return service({
      url: '/user/loginApi',
      method: 'post',
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data,
    });
}